package com.sskj.xgja.message;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.flyco.tablayout.listener.CustomTabEntity;
import com.sskj.base.view.CommonTabLayout;
import com.sskj.xgja.MVPFragment;
import com.sskj.base.entry.TabItem;
import com.sskj.xgja.R;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * @author Hey
 * Create at  2019/03/20
 */
public class MessageHomeFragment extends MVPFragment<MessageHomePresenter> {

    @BindView(R.id.tabLayout)
    CommonTabLayout tabLayout;

    private ArrayList<CustomTabEntity> tabs = new ArrayList<>();
    private ArrayList<Fragment> fragments = new ArrayList<>();

    @Override
    public int getLayoutId() {
        return R.layout.fragment_message_home;
    }

    @Override
    public MessageHomePresenter getPresenter() {
        return new MessageHomePresenter();
    }

    @Override
    public void initView() {
        fragments.add(MessageFragment.newInstance());
        fragments.add(NoticeFragment.newInstance());
        tabs.add(new TabItem("行业资讯"));
        tabs.add(new TabItem("平台新闻"));
        tabLayout.setTabData(tabs, getChildFragmentManager(), R.id.message_content, fragments);
    }

    @Override
    public void initData() {

    }

    public static MessageHomeFragment newInstance() {
        MessageHomeFragment fragment = new MessageHomeFragment();
        Bundle bundle = new Bundle();
        fragment.setArguments(bundle);
        return fragment;
    }


    public void setIndex(int childIndex) {
        tabLayout.setCurrentTab(childIndex);
    }
}
